package com.lh.controller;

import com.alibaba.fastjson2.JSONObject;
import com.lh.disruptor.DisruptorServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;

/**
 * @author: linghao
 * @since: 2025/5/24
 */
@RestController
public class DisruptorControll {

    @Autowired
    private DisruptorServer disruptorServer;

    @PostMapping("/testDisruptor")
    public Object testDisruptor(@RequestBody JSONObject param){
        DeferredResult<Object> deferredResult = new DeferredResult<>(2000L);
        disruptorServer.publishDeferred(param,deferredResult);
        return deferredResult;
    }
}
